package com.yanqu.road.server.cmd.systemgroup.newmonopolymkt.resgrab;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.newmonopolymkt.NewMonopolyMarketProto;
import com.yanqu.road.server.cmd.CrossAppointCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.monopolymarket.MonopolyMarketResGrabMgr;
import com.yanqu.road.server.manager.systemgroup.newmonopolymkt.CrossNewMonopolyMarketGroup;
import com.yanqu.road.server.manager.systemgroup.newmonopolymkt.CrossNewMonopolyMarketMgr;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;


@Cmd(code = Protocol.C_CROSS_NEW_MONOPOLY_MARKET_RES_GRAB_GET_USER_POINT, desc = "资源争夺战 查看玩家所采集的据点")
public class CrossNewMonopolyMarketResGrabGetUserPointCmd extends CrossAppointCommand {

    private int type ;
    private long searchServerId;
    private long userId ;
    private int resType ;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        NewMonopolyMarketProto.NewMonopolyMarketResGrabGetUserPointReqMsg req = NewMonopolyMarketProto.NewMonopolyMarketResGrabGetUserPointReqMsg.parseFrom(packet.getBytes());
        type = req.getType();
        searchServerId = req.getServerId();
        userId = req.getUserId();
        resType = req.getResType();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

        CrossNewMonopolyMarketGroup monopolyMarket = CrossNewMonopolyMarketMgr.getMarket(groupId);
        if(monopolyMarket == null){
            //todo
            return;
        }

        MessageHelper.sendPacket(serverId, packet.getPlayerId() , YanQuMessageUtils.buildMessage(ClientProtocol.U_NEW_MONOPOLY_MARKET_RES_GRAB_GET_USER_POINT,
                monopolyMarket.getMarketResRob().getUserPoint(serverId, type, resType, searchServerId, userId)));
    }

    @Override
    public void sendData() {

    }
}
